import requests,json

appKey = '0757a796911448cfb4d100425ceeea8e'
userId = 'ffc37499905a7fcf'

question = ''


while question != 'N':
    question = input('请输入你的问题：')
    distData = {
        "perception": {
            "inputText": {
                "text": question
            },

        },
        "userInfo": {
            "apiKey": appKey,
            "userId": 'fool'
        }
    }
    jsonData = json.dumps(distData)

    res = requests.post('http://openapi.tuling123.com/openapi/api/v2',jsonData)
    jsonRes = json.loads(res.text)
    answer = jsonRes['results'][0]['values']['text']
    print(answer)
    # 把结果打印出来
    question = input('是否继续询问呢,回复Y/N：')
print('欢迎您的下次提问')    













